﻿using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;

using Com.Ompchina.Lib.DBHelper;
using Model.AuthModel;
using IDAL.AuthModel;
namespace SQLServerDAL.AuthModel
{
    /// <summary>
    /// 通用组件，权限模型，数据层，角色权限
    /// </summary>
    public class RolesAuthDAL : DalBase, IRolesAuth
    {
        public RolesAuthDAL() 
        {
            Schema = "am.";
        }

        #region IRolesAuth 成员
        /// <summary>
        /// 更新角色的授权
        /// </summary>
        /// <param name="rolesID">角色编号</param>
        /// <param name="authList">权限列表</param>
        /// <returns></returns>
        public bool UpdateRolesAuth(int rolesID, string authList)
        {
            SqlParameter[] parm = new SqlParameter[] {                
                new SqlParameter("@RolesID",SqlDbType.Int)
                ,new SqlParameter("@AuthList",SqlDbType.VarChar,1000)
                ,new SqlParameter("@RtnCode",SqlDbType.Char,2)
            };
            int i=0;
            parm[i++].Value = rolesID;
            parm[i++].Value = authList;
            parm[i++].Direction = ParameterDirection.Output;
            SqlHelper.ExecuteNonQuery(base.ConnectionString, CommandType.StoredProcedure, Schema + "UpdateRolesAuth", parm);
            return parm[parm.Length - 1].Value.ToString().Equals("80");
        }
        #endregion
    }
}
